import grok
import biro

from megrok.kss import KSS

grok.templatedir('admin_templates')
grok.context(biro.Biro)

class BiroAdmin(grok.View):
    grok.name('admin')
    grok.template('adminmaster')
    grok.require('biro.Admin')
    
    @property
    def blogtitle(self):
        if self.context.blogtitle == "Blog Title": #Title still uncustomized
            return "Click here to custumize title"

        return self.context.blogtitle
    
    def update(self, title=None):
        if title != None:
            self.context.blogtitle = title

class Provola(grok.View):
    def render(self):
        return '<input class="blogtitle title" id="title" name="title" type="text" value="%s"/>' % self.context.blogtitle

class TestKSS(KSS):
    grok.view(BiroAdmin)
    
    def welcome(self):
        core = self.getCommandSet('core')
        core.replaceHTML('#blogtitle', Provola(self.context, self.request).render())
